SHELL := /bin/bash

COMPILE_ROOT := $(shell pwd)
MIDDLEWARE_DIR := $(COMPILE_ROOT)/../../..
include $(MIDDLEWARE_DIR)/base.mak
NDK_ROOT := $(MIDDLEWARE_DIR)/ndk
SDK_LINK_ROOT := $(DEP_DIR)
NDK_LINK_ROOT := ndk
MPP_ROOT := $(SDK_ROOT)/amp/a7_linux/mpp
ADAS_STATIC_LIB := libmw_adas_adpt.a
ADAS_SHARED_LIB := libmw_adas_adpt.so


PROC_SRCS := $(COMPILE_ROOT)
PROC_OBJ := $(patsubst %.cpp,%.o, $(PROC_SRCS))
SRCS := $(filter-out $(PROC_SRCS),$(wildcard *.cpp))
$(warning ========================)
$(warning $(SRCS))
$(warning ========================)
OBJS := $(filter-out $(PROC_OBJ),$(patsubst %.cpp,%.o, $(notdir $(SRCS))))

INCLUDE_PATH := -I../include \
	-I$(MPP_ROOT)/include \
	-I$(SDK_ROOT)/amp/a7_liteos/mpp/include \
	-I$(SDK_ROOT)/amp/a7_linux/hisyslink/datafifo/include \
	-I$(SDK_ROOT)/amp/a7_linux/hisyslink/ipcmsg/include \
	-I$(SDK_ROOT)/amp/a7_linux/drv/extdrv/userproc/include \
	-I$(NDK_ROOT)/code/mediaserver/adapt/aenc/include \
	-I$(NDK_ROOT)/out/hi3559v200/dual/host/include \
	-I$(NDK_ROOT)/code/include \
	-I$(MIDDLEWARE_DIR)/media_adpt/include

.PHONY: all adas

all: $(ADAS_STATIC_LIB) $(ADAS_SHARED_LIB)

$(ADAS_STATIC_LIB): $(OBJS)
	$(AT)$(AR) -rcv $@ $^

$(ADAS_SHARED_LIB): $(OBJS)
	$(AT)$(CXX) $(CFLAGS) $(LFLAGS) -fPIC -shared -o $@ $^

$(OBJS):%.o:%.cpp
	$(AT)$(CXX) $(CFLAGS) -c $< -o $@ $(INCLUDE_PATH)

clean:
	rm -fv *.o
	rm -fv *.a
	rm -fv *.so
	rm -rf $(OBJS)
